package field_REGEX_Definitions.Other;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import field_REGEX_Definitions.Field;
import fields.*;

public class URL_Source implements Field{
	private Pattern source_URL = Pattern.compile("source:[\\n\\s]*(\\S*)",Pattern.CASE_INSENSITIVE);
	private String field;
	private String type = "other";
	private String rest = "";
	public boolean matches(String input) {
		Matcher matcher = source_URL.matcher(input);
		boolean result = matcher.find();
		if (result) {
			field = "Source Website";
			rest = matcher.group(1);
		}
		return result;
	}
	
	public String getFieldName(){
		return field;
	}

	public FileCollectionData execute() {
		return new FileCollectionData(field,"Other",rest);
	}

	@Override
	public String getFieldType() {
		return type;
	}
}
